package eval.deploy;

import cern.jet.random.AbstractDistribution;
import eval.utilities.configuration.ExperimentConfiguration;
import eval.utilities.random.ProbabilisticDistributionsEnum;
import eval.vm.VMConfiguration;


public class VMRealDemand {

	private static ExperimentConfiguration conf = ExperimentConfiguration.getSingleton();

	private int[] cpuDemand;
	private int[] memDemand;
//	private int[] cpuLoud;
	

	public VMRealDemand(AbstractDistribution CPUdemandDistribution,int MEMDemand,VMConfiguration vmConfiguration) {
		this.cpuDemand = new int[conf.experimentTicks];
		this.memDemand = new int[conf.experimentTicks];
		//this.cpuLoud = new int[conf.experimentTicks];
		initHistory(CPUdemandDistribution,MEMDemand);
	}

	private void initHistory(AbstractDistribution demandDistribution,int MEMDemand) {
		for (int i = 0; i < cpuDemand.length; i++) {
			switch (ProbabilisticDistributionsEnum
					.valueOf(conf.demandDistribution)) {
			case CONSTANT:
				cpuDemand[i] = conf.cpuDemandDistributionVal;
				memDemand[i] = conf.memDemandDistributionVal;
				break;
			default:
				cpuDemand[i] = demandDistribution.nextInt();
				memDemand[i] = MEMDemand;
				break;
			}
		}
	}

	public int getCPUDemandAtTick(int tick) {
		return cpuDemand[tick];
	}
	
	public int getMEMDemandAtTick(int tick) {
		return memDemand[tick];
	}
}
